﻿namespace UserStories.Models
{
    using System.Collections.Generic;

    public class User
    {
        public int Id { get; set; }

        public string Name { get; set; }

        public string Email { get; set; }

        public string UserName { get; set; }

        public string Password { get; set; }

        public Dictionary<int,Role> Roles { get; set; }

        public bool IsSysAdmin { get; set; }

        public User()
        {
            Roles = new Dictionary<int, Role>();
        }

        public Role RoleInProject(Project project)
        {
            return Roles.ContainsKey(project.Id)? Roles[project.Id] : null;
        }

        public bool IsRoleInProject(int projectId, Role role)
        {
            return Roles.ContainsKey(projectId) && Roles[projectId].Id == role.Id;
        }
    }
}